{% macro getData() %}
{% macro doIt(val) %}
{{ deferred ~ val|tojson }}
{% endmacro %}

{% for val in [{'a': 'a'}, {'b': 'b'}] %}
{{ doIt(val)|upper }}
{% endfor %}
{% endmacro %}

{{ getData()|upper }}
